package andrei.mower2.business;

import andrei.mower2.business.Mower.Command;
import andrei.mower2.business.Mower.Direction;

final class Compass {

	private static final Compass INSTANCE = new Compass();
	private static final Direction[] COMPASS_DIRECTIONS = {Mower.Direction.N, Mower.Direction.E, Mower.Direction.S, Mower.Direction.W};
	
	Compass() {}
	
	static Compass getInstance() {
		return INSTANCE;
	}
	
	Direction rotateCW(Direction currentDirection, Command command) {
		short rotationDegrees = (short) (command.rotationDegreesDeltaCW + currentDirection.degreesFromNorthCW);	
		return COMPASS_DIRECTIONS[(4+(rotationDegrees/90))%4];
	}
}
